package com.qf.day07;

import com.sun.deploy.perf.DefaultPerfHelper;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class WeaponGenerator {
    private static final String[] POSSIBLE_WEAPONS = {"长剑", "匕首", "弓箭", "法杖", "盾牌"};

    public static Weapon[] generateRandomWeapons(int count) {
        if (count < 1 || count > POSSIBLE_WEAPONS.length) {
            throw new IllegalArgumentException("在掉落的物品中选择一个");
        }


        List<Weapon> weaponsList = new ArrayList<>();
        Random random = new Random();

        for (int i = 0; i < count; i++) {
            int randomIndex = random.nextInt(POSSIBLE_WEAPONS.length);
            Weapon weapon = new Weapon(POSSIBLE_WEAPONS[randomIndex]);
            weaponsList.add(weapon);
        }

        return weaponsList.toArray(new Weapon[0]);
    }


    public static void main(String[] args) {
        Weapon[] weapons = generateRandomWeapons(5);

        for (Weapon weapon : weapons) {
            System.out.println(weapon);
        }
    }
}
